<div class="index_wrapper">
	<?php include PROJECT_PATH . 'Application/View/menu.tpl.php';?>
	<div class="content">
	    <div class="title">
	    	<div>
	        	<input id="date" class="hover search_date" value="<?=$date?>" type="text" onClick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM',lang:'zh-cn'})">
	    	</div>
	    	<div>
	    		<select id="flg" class="hover search_select">
		            <option value="0" <?php if($search['flg'] == 0){?>selected="selected"<?php }?>>All</option>
		            <option value="1" <?php if($search['flg'] == 1){?>selected="selected"<?php }?>>Casting</option>
		            <option value="2" <?php if($search['flg'] == 2){?>selected="selected"<?php }?>>Work</option>
		        </select>
	    	</div>
	    	<div>
	    		<input id="modelname" class="text search_model" type="text" value="<?=$search['modelname']?>">
	    	</div>
	    	<div>
	    		<input id="username" class="text search_user" type="text" value="<?=$search['username']?>">
	    	</div>
	    	<div>
	    		<div id="search" class="search_btn hover" onclick="search();"></div>
	    	</div>
	    	<div>
	    		<?php if(Model_User::getLevelID() == 5){?>
	    			<div id="download" class="search_down hover" onclick="download();"></div>
	    		<?php }else{?>
	    			<div id="download" class="search_down_notshow"></div>
	    		<?php }?>
	    	</div>
	    </div>
	    <div class="result">
	        <?php foreach($works as $day=>$work){?>
	        <div class="data_wrapper" onclick="detail('detailshow_<?=$day?>');">
	        	<div>
	            	<div class="data_title"><?php echo $day . '<br>';?></div>
	            </div>
	            <div class="data hover">
	            	<?php if(isset($work['work'])){?>
	                <?php foreach($work['work'] as $job){?>
	                <div class="info <?php if($job['type'] == '出差' || $job['type'] == '回京'){echo 'bluecolor';}else if($job['flg'] == '面试'){ echo 'balckcolor';}else{ echo 'redcolor';}?>">
	                    <span><?=$job['enflg']?></span>
	                    <span><?=$job['entype']?></span>
	                    <span><?=$job['username']?></span>
	                    <span><?=$job['modelnamestr']?></span>
	                    <?php if($job['sure'] == 1){?>
	                    	<span>UnSure</span>
	                    <?php }?>
	                </div>
	                <?php }?>
	                <?php }?>
	                <?php if(isset($work['modelstate'])){?>
	                	<?php foreach ($work['modelstate'] as $modelstate){ ?>
	                		<div class="info bluecolor">
	                			<span><?=$modelstate['name']?><?php if($modelstate['flg'] == 0){echo ' Come to Beijing';}else{echo ' Leave Beijing';}?></span>
	                		</div>
	                	<?php }?>
	                <?php }?>
	            </div>
	        </div>
	        <div class="detailshow_wrapper">
	        <div class="detailshow" id="detailshow_<?=$day?>">
	            <div class="close hover" onclick="hide('detailshow_<?=$day?>')">
	            	<img src="<?=IMG_PATH?>/fancybox.png" class="close_img">
	            </div>
	            <div class="time_title"><?=Model_Common::getFormatTimeYMD(Model_Common::getStampTime($date . "-" . $day))?></div>
	            <table>
	                <tr>
	                    <td class="table_title table_title_time">Time</td>
	                    <td class="table_title table_title_flg">Project</td>
	                    <td class="table_title table_title_type">Type</td>
	                    <td class="table_title table_title_username">Booker</td>
	                    <td class="table_title table_title_model">Model</td>
	                    <?php if(Model_User::getLevelID() != 1){?>
	                    <td class="table_title table_title_info">Detail</td>
	                    <td class="table_title table_title_operate">OP</td>
	                    <?php }?>
	                </tr>
	                <?php if(isset($work['work'])){?>
	            	<?php foreach($work['work'] as $job){?>
	                <tr class="<?php if($job['type'] == '出差' || $job['type'] == '回京'){echo 'bluecolor';}else if($job['flg'] == '面试'){ echo 'balckcolor';}else{ echo 'redcolor';}?>">
	                    <td class="center"><?=$job['time']?></td>
	                    <td class="center"><?=$job['enflg']?></td>
	                    <td class="center"><?=$job['entype']?></td>
	                    <td class="center"><?=$job['username']?></td>
	                    <td>
	                    	<?php foreach($job['modelname'] as $name=>$id){?>
	                    	<a class="<?php if($job['type'] == '出差' || $job['type'] == '回京'){echo 'bluecolor';}else if($job['flg'] == '面试'){ echo 'balckcolor';}else{ echo 'redcolor';}?>" target="_blank" href="http://<?=HOST?>/model/detail/modelid/<?=$id?>">
	                    		<?php echo Model_Model::getNicksByNameStr($name) . '; '?>
	                    	</a>
	                    	<?php }?>
	                    </td>
	                    <?php if(Model_User::getLevelID() != 1){?>
	                    <td><?=$job['info']?></td>
	                    <td class="center"><a class="<?php if($job['type'] == '出差' || $job['type'] == '回京'){echo 'bluecolor';}else if($job['flg'] == '面试'){ echo 'balckcolor';}else{ echo 'redcolor';}?>" target="_blank" href="http://<?=HOST?>/work/detail/workid/<?=$job['workid']?>">详情</a></td>
	                	<?php }?>
	                </tr>
	           		<?php }?>
	           		<?php }?>
	            </table>
	            <div class="modelstate">
	                <?php if(isset($work['modelstate'])){?>
	                	<?php foreach ($work['modelstate'] as $modelstate){ ?>
	                		<div class="bluecolor info">
	                			<span><?=$modelstate['name']?><?php if($modelstate['flg'] == 0){echo ' 来京';}else{echo ' 离京';}?></span>
	                		</div>
	                	<?php }?>
	                <?php }?>
	            </div>
	        </div>
	        </div>
	        <?php }?>
	    </div>
	</div>
</div>
<script type="text/javascript">
    function search()
    {
        location.href = 'http://<?=HOST?>/index/index/date/' + $('#date').val() + '/flg/' + $('#flg').val() + '/modelname/' + $('#modelname').val() + '/username/' + $('#username').val();
    }
    function download()
    {
        location.href = 'http://<?=HOST?>/index/download/date/' + $('#date').val() + '/flg/' + $('#flg').val() + '/modelname/' + $('#modelname').val() + '/username/' + $('#username').val();
    }    
    function detail(id)
    {
        $("#disable").show();
        $("#"+id).show();
    }
    function hide(id)
    {
        $("#disable").hide();
        $("#"+id).hide();
    }
</script>


